package com.wistech.search.solr.qp;

import java.util.Map;

import org.apache.solr.common.params.SolrParams;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.util.SolrPluginUtils;

public class WisDisMaxQParser extends org.apache.solr.search.DisMaxQParser {
	private static String IMPOSSIBLE_FIELD_NAME = "\uFFFC\uFFFC\uFFFC";

	public WisDisMaxQParser(String qstr, SolrParams localParams,
			SolrParams params, SolrQueryRequest req) {
		super(qstr, localParams, params, req);
	}

	protected SolrPluginUtils.DisjunctionMaxQueryParser getParser(
			Map<String, Float> fields, String paramName, SolrParams solrParams,
			float tiebreaker) {
		int slop = solrParams.getInt(paramName, 0);
		SolrPluginUtils.DisjunctionMaxQueryParser parser = new WisDisjunctionMaxQueryParser(
				this, IMPOSSIBLE_FIELD_NAME);
		parser.addAlias(IMPOSSIBLE_FIELD_NAME, tiebreaker, fields);
		parser.setPhraseSlop(slop);
		return parser;
	}

}
